package xyf.p11.other.twopointer;

/**
 * ClassName: P0283_ZeroMove
 * Description:
 * Author: xyf
 * Date: 9/9/22 10:22 AM
 * Version: 1.0
 **/
public class P0283_ZeroMove
{
    public void moveZeroes(int[] nums)
    {
        int n = nums.length, left = 0, right = 0;
        while (right < n)
        {
            if (nums[right] != 0)
            {
                swap(nums, left, right);
                left++;
            }
            right++;
        }
    }

    public void swap(int[] nums, int left, int right)
    {
        int temp = nums[left];
        nums[left] = nums[right];
        nums[right] = temp;
    }
}
